/*
	--Art Ordonez
	--polygon.h
	--		contains helper functions from the Canvas class
	--		@Credit to Dr. Rague
*/

#ifndef POLYGON_H
#define POLYGON_H

const int CIRCLE = 1;
const int TRIANGLE = 3;
const int RECTANGLE = 4;

class Point2   //single point w/ floating point coordinates
{
public:
	Point2() {x = y = 0.0f;} //constructor 1
	Point2(float xx, float yy) {x=xx; y=yy;} //constructor 2
	void set(float xx, float yy) {x=xx; y=yy;}
	void draw()
	{
		glColor3f(0.0, 10.0, 0.0);
		glPointSize(10.0);
		glBegin(GL_POINTS);
			glVertex2f(x, y);
		glEnd();
		glFlush();
	}
	float getX() {return x;}
	float getY() {return y;}
private:
	float x, y;
};

class CPolygon
{
public:
	//changes current point
	void moveTo(float x, float y);

	//draws a line from current point to new point
	void lineTo(float x, float y);

	void drawCross();																// Draws a crosshair on polygon

	void draw(int n, float cx, float cy, float side, float rotAngle);
	// draw two basic polygons and a circle

	void drawRectangle(Point2 ctr, float side);										// Draws a Square
	void drawTriangle(Point2 ctr, float side);										// Draws an equilateral triangle
	void drawCircle(Point2 ctr, float radius);										// Draws a circle

	void onDraw();
	CPolygon();
	void setCtr(float x, float y){ctr.set(x, y);}

	void setType(int pt);
	void setSize(float s);

	float getSize()
	{
		return size;
	}

	Point2 getCtr()
	{
		return ctr;
	}
private:
	int polyType;
	float size;
	Point2 ctr;
	Point2 drawPt;
	float dir;
};

#endif